package com.dnjn.happiness.common.amqp;

import com.dnjn.happiness.common.core.score.dto.HappyDTO;
import com.dnjn.happiness.common.core.score.vo.HappyVO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author amber
 * @version 1.0
 * @description TODO
 * @date 2024/6/5 16:57
 **/
@Component
public class AmqpSender {

    protected static RabbitTemplate RABBIT_TEMPLATE;

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(/*AmqpTemplate amqpTemplate,*/) {
        AmqpSender.RABBIT_TEMPLATE = rabbitTemplate;
    }

    public static void sendArgs(final HappyVO vo) {
        RABBIT_TEMPLATE.convertAndSend(AmqpConst.SCORE_EXCHANGE_NAME, AmqpConst.SCORE_ROUTING_KEY, vo);
    }

    public static void sendUserScore(final HappyDTO dto) {
        RABBIT_TEMPLATE.convertAndSend(AmqpConst.SCORE_RESULT_EXCHANGE_NAME, AmqpConst.SCORE_RESULT_ROUTING_KEY, dto);
    }

}
